<template>
	<view class="bgw">
		  <view class="cu-list menu-avatar">
		  	<view class="cu-item">
		  		<view class="cu-avatar round lg" :style="'background-image:url('+data.logo+'?imageView2/2/w/80);'"></view>
		  		<view class="content">
		  			<view class="text-grey">{{data.store_name}}</view>
		  			<!-- <view class="text-gray text-sm flex">
		  				<view class="text-cut">
		  					<text class="cuIcon-infofill text-green margin-right-xs"></text>
		  					 
		  				</view> </view> -->
		  		</view>
		  		 
		  	</view>
			</view>
			 
			<view class="padding-xl">
				 <view class="text-center padding-xl ">绑定账户或登录管理后台, 确认操作吗?</view>
				<button @click="getopenid" class="cu-btn block bg-blue margin-tb-sm lg">
					<text class="cuIcon-loading2 cuIconfont-spin" v-if="loadding"></text> 确认操作</button>
	 
			</view>
		  	
	</view>
</template>

<script>
import beeApp from '../../beeApp.js';
export default {
	data() {
		return {
			 data:{},
			 loadding:0,
			 index: -1,
			 money:"",
			 order_type:'',
			 picker: [],
			 shop_id:357,
		};
	},
	onShareAppMessage(res) {
	    
	  },
	  onPullDownRefresh() {
		  this.loadding=0;
		  this.loadData();
	  	 wx.stopPullDownRefresh();
	  },
	onLoad(query) {
			const url = decodeURIComponent(query.q) // 获取到二维码原始链接内容
			this.reqId = this.getQueryVariable(url,"reqId");
			console.log("url:",url,"this.reqId:",this.reqId);
			this.loadData();
		},
		
		methods: {
			 getQueryVariable(url="",variable)
			 {
			 	   let p = url.split("?")
			        var query = p[1];
			        var vars = query.split("&");
			        for (var i=0;i<vars.length;i++) {
			                var pair = vars[i].split("=");
			                if(pair[0] == variable){return pair[1];}
			        }
			        return(false);
			 },
			loadData(){
				// this.getopenid();
					var that = this;
					beeApp.api("apiv2/pay/community_fee_type_list", {
						shop_id:357
					}, function (res) {
					 if(res.code!=200){
						 beeApp.alert(res.msg);
						 return;
					 }
					that.data= res.data;
					for(var i in res.data.list ){
						that.picker.push(res.data.list[i].cost_type);
					}
					  
					
					})
			},
			getopenid(){
				// var openid =  uni.getStorageSync("openid");
				// if(openid ){
				// 	this.openid =openid;
				// 	return;
				// } 
				var that = this;
				wx.login({
				  success (res) {
					  console.log("res:",res);
				    if (res.code) {  
					   that.code = res.code;
					   that.login();
				    } else {
				      beeApp.alert('登录失败！' + res.errMsg)
				    }
				  }
				})
			},
			login:function(){
				 
			  
			            
			  if(this.loadding==1){
				  return;
			  }
			  var that = this;
				
			  
			  this.loadding=1;
			  
			  beeApp.api("/api/user/bindOpenIdUserID",{
				  code:this.code,
				  reqId: this.reqId,
				  method:"POST",
			  },function(res){
				   that.loadding=0;
			      if(res.code!=200){
					
			        beeApp.alert(res.msg);
			        return;
			      }
				   beeApp.alert(res.msg);
			     
			  });
			  // console.log(bill_entry_ids);
			}
			
		}
			   
	
	
};
</script>

<style>

	.menu-list {
		box-shadow: 0px 3px 0px #eee;
		width: 96%;
		border-radius: 5%;
		margin-top: -70upx;
		position: absolute;
		left: 2%;
		white-space: nowrap;
		background-color: #fff;
		padding: 10upx 0;
	}

	.least-recently-used {
		overflow-x: auto;
		overflow-y: hidden;
		white-space: nowrap;
		-webkit-overflow-scrolling: touch;
	}

	.least-recently-used .used-item {
		display: inline-block;
		width: 25%;
		text-align: center;
		padding: 15upx 0;
	}

	.least-recently-used .used-item image {
		width: 50upx;
		height: 50upx;
	}

	.used-item3 {
		display: inline-block;
		width: 25%;
		text-align: center;
		padding: 15upx 0;

	}

	.used-item3 image {
		width: 80upx;
		height: 80upx;
	}

	.aui-row-title {
		padding: 20rpx 0px 0px 40rpx;
	}

	.notiBox {
		box-shadow: 0px 3px 0px #eee;
		border-radius: 5%;
		border: 1px solid #eee;
		margin: 10px;
	}

	.screen-swiper {
		min-height: 300upx;
		height: 300upx;
	}

	.least-recently-used .used-item2 {
		display: inline-block;
		width: 80%;
		box-shadow: 0px 3px 0px #eee;
		border-radius: 5%;
		border: 1px solid #eee;

		margin: 0 5px;

	}

	.least-recently-used .used-item2 image {
		width: 100upx;
	}

	.used-item2 image {
		width: 100upx;
	}


	.footer .l-line,
	.footer .r-line,
	.footer .footer-content {
		float: left;
		color: #888;
	}

	.footer {
		width: 560upx;
		margin: 0 auto;
		margin-top: 40upx;
	}

	.footer .l-line,
	.footer .r-line {
		width: 68upx;
		border-bottom: 1px solid #888;
		margin-top: 60upx;
	}

	.footer-content {
		padding: 40upx 10upx;
	}
</style>
